package com.wtwd.wtwddevice.service.impl;


import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.wtwd.wtwddevice.mapper.DeviceBloodOxygenTotalMapper;
import com.wtwd.wtwddevice.model.entity.DeviceBloodOxygenTotal;
import com.wtwd.wtwddevice.service.IDeviceBloodOxygenTotalService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author mjy
 * @since 2024-05-29
 */
@Service
public class DeviceBloodOxygenTotalServiceImpl extends ServiceImpl<DeviceBloodOxygenTotalMapper, DeviceBloodOxygenTotal> implements IDeviceBloodOxygenTotalService {


    @Resource
    private DeviceBloodOxygenTotalMapper deviceBloodOxygenTotalMapper;


    @Override
    public boolean insertOrUpdate(DeviceBloodOxygenTotal deviceBloodOxygenTotal) {
        if (deviceBloodOxygenTotal == null) return false;
        return deviceBloodOxygenTotalMapper.insertOrUpdate(deviceBloodOxygenTotal) > 0 ? true : false;
    }

    @Override
    public DeviceBloodOxygenTotal getDeviceBloodOxygenTotal(Long deviceId, String time) {
        return new LambdaQueryChainWrapper<>(deviceBloodOxygenTotalMapper)
                .eq(DeviceBloodOxygenTotal::getDeviceId, deviceId)
                .eq(DeviceBloodOxygenTotal::getTime, time)
                .one();
    }
}
